using GameUI;
using Inventory;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DiscardField:UIElementControllerBase, ITransferrable {

	public Sprite itemSprite => null;
	public object contentItem => null;
	public bool canTake => false;

	public bool Choose() => false;

	public bool DoAccept(object content) {
		if(content is ItemBase) return true;
		if(content is WeaponInstance) return true;
		if(content is UpgradeInstance) return true;
		return false;
	}

	public void Return() { }

	public bool TryAccept(object content) {
		if(!DoAccept(content)) return false;
		if(content is ItemBase) ItemPickup.Create(Player.instance.position,content as ItemBase);
		if(content is WeaponInstance) WeaponPickup.Create(Player.instance.position,content as WeaponInstance);
		if(content is UpgradeInstance) UpgradePickup.Create(Player.instance.position,content as UpgradeInstance);
		return true;

	}

	protected override void OnPointerRelease() {
		base.OnPointerRelease();
		if(InventoryUIController.instance.mouseItem!=null) {
			object itemToTake = InventoryUIController.instance.mouseItem.contentItem;
			if(!DoAccept(itemToTake)) return;
			if(!InventoryUIController.instance.TryTakeMouseItem()) return;
			TryAccept(itemToTake);
		}
	}

	public bool TryTake() => false;
}
